package com.liuzu.esys.controller;

import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.common.R;
import com.liuzu.esys.pojo.FinTotal;
import com.liuzu.esys.service.FinTotalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author : 松松
 * @date : 2022/7/27
 * @desc : 总财务功能实现
 */

@RestController
@RequestMapping("/fintotal")
public class FinTotalController {

    @Autowired
    private FinTotalService finTotalService;


    //查询总财务信息列表
    @RequestMapping("/ftlist")
    public LayuiPageVo<FinTotal> ftList(@RequestParam Map<String, Object> params) {
        System.out.println(params);
        return finTotalService.ftList(params);
    }

    //添加总财务信息
    @RequestMapping("/ftadd")
    public R ftadd(FinTotal finTotal) {
        int flag = finTotalService.addft(finTotal);

        if (flag == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }


    //删除总财务信息
    @GetMapping("/ftdel")
    public R ftdel(Integer id) {
        int flag = finTotalService.delft(id);
        if (flag == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }


    //修改总财务信息
    @GetMapping("ftset")
    public R ftset(FinTotal finTotal) {
        int flag = finTotalService.setft(finTotal);
        if (flag == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }

}
